$(document).ready(function () {  
    $(".tabContent img").each(function () {  
        DrawImage(this, 170, 170);
    });  
});  
$(document).ready(function() {
	$(".medium").each(function () {  
        DrawImage(this, 300, 300);
    });
});
$(document).ready(function() {
	$("#result img").each(function () {  
        DrawImage(this, 170, 170);
    });
});
$(document).ready(function() {
	$(".cartimg").each(function () {  
        DrawImage(this, 60, 60);
    });
});

$(document).ready(function() {
	$(".orderlistimg").each(function () {  
        DrawImage(this, 60, 60);
    });
});

$(document).ready(function() {
	$(".orderimg").each(function () {  
        DrawImage(this, 60, 60);
    });
});
function delay(){
	
}

function DrawImage(ImgD, FitWidth, FitHeight) {  
    var image = new Image();  
    image.src = ImgD.src;
    image.onload =function() {
    if (image.width > 0 && image.height > 0) {  
        if (image.width / image.height >= FitWidth / FitHeight) {  
            if (image.width > FitWidth) {
            	setTimeout("delay();",500);
                ImgD.width = FitWidth;  
                ImgD.height = (image.height * FitWidth) / image.width; 
                
                ImgD.style.marginBottom = -(ImgD.height - FitHeight)/2 + "px";
            } else {
            	setTimeout("delay();",500);
                ImgD.width = image.width;  
                ImgD.height = image.height;
                
                ImgD.style.marginBottom = -(ImgD.height - FitHeight)/2 + "px";
            }  
        } else {  
            if (image.height > FitHeight) {
            	setTimeout("delay();",500);
                ImgD.height = FitHeight;  
                ImgD.width = (image.width * FitHeight) / image.height;  
                ImgD.style.marginLeft = -(ImgD.width - FitWidth)/2 + "px";
                ImgD.style.marginRight = -(ImgD.width - FitWidth)/2 + "px";
            } else {
            	setTimeout("delay();",500);
                ImgD.width = image.width;  
                ImgD.height = image.height;
                ImgD.style.marginLeft = -(ImgD.width - FitWidth)/2 + "px";
                ImgD.style.marginRight = -(ImgD.width - FitWidth)/2 + "px";
            }  
        }  
    } 
    
 }
}
   